﻿package com.hatch.ui {
	import flash.display.Sprite;
	/**
	 * A Box
	 * 
	 * This is resizable box that is useful for quick drawing and also
	 * serves as a simple component demonstration.
	 */
	public class Box extends Component 	{
		private var _color:Number = 0;
		private var _cornerRadius:Number = 0;
		public function Box( color:Number = 0, width:Number = 64, height:Number = 64, x:Number = 0, y:Number = 0, cornerRadius:Number = 0 ) 		{
			super();		
			_color = color;		
			_cornerRadius = cornerRadius;	
			this.x = x;
			this.y = y;
			setSize(width, height);
		}
		public function set color(val:Number):void 		{
			_color = val;
			invalidate();
		}
		public function get color():Number 		{
			return _color;
		}
		public function set cornerRadius(val:Number):void 		{
			_cornerRadius = val;
			invalidate();
		}
		public function get cornerRadius():Number 		{
			return _cornerRadius;
		}
		override public function draw():void 		{
			super.draw();
			
			graphics.clear();
			graphics.beginFill(color);
			graphics.drawRoundRect(0, 0, width, height, cornerRadius, cornerRadius);
			graphics.endFill();			
		}
		override public function set width(value:Number):void
		{
			super.width = value;
		}
		override public function set height(value:Number):void
		{
			super.height = value;
		}
	}
}